<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Projet Jetpack:  Fichier source de /home/p1006250/lif7-projet-jetpack/src/Terrain.c</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Projet Jetpack
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Généré par Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Page&#160;principale</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Fichiers</span></a></li>
      <li><a href="dirs.html"><span>Répertoires</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>Liste&#160;des&#160;fichiers</span></a></li>
      <li><a href="globals.html"><span>Membres&#160;de&#160;fichier</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_terrain_8c.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">Terrain.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_terrain_8c.html">Aller à la documentation de ce fichier.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &quot;<a class="code" href="_terrain_8h.html">Terrain.h</a>&quot;</span>
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 
<a name="l00005"></a><a class="code" href="_terrain_8h.html#aa3b3da7033de7e4286324e724ec4eaed">00005</a> <span class="keywordtype">void</span> <a class="code" href="_terrain_8c.html#aa3b3da7033de7e4286324e724ec4eaed" title=" Brief Description  initialise le terrain.  ">terInit</a>(<a class="code" href="structs_terrain.html">Terrain</a> * <a class="code" href="struct_ssprite.html#ac66841fecf0c4dc876df62666230397f">pTer</a>, <a class="code" href="structs_terrain.html">Terrain</a> * pTersuiv)
<a name="l00006"></a>00006 {
<a name="l00007"></a>00007     <span class="keywordtype">char</span> chemin[18];
<a name="l00008"></a>00008     <a class="code" href="_terrain_8c.html#a65ce23314928441923707ec041871779">chargerTerrain</a>(pTer, <span class="stringliteral">&quot;data/NiveauDépart.txt&quot;</span>,<a class="code" href="_sdl_jeu_8h.html#a6068a247ff9ece1b0a9773c58144906c">LARGEUR_FENETRE</a>,<a class="code" href="_sdl_jeu_8h.html#afd1a1e285af564b849b17498e82e1a41">HAUTEUR_FENETRE</a>);
<a name="l00009"></a>00009     <a class="code" href="_terrain_8c.html#a65ce23314928441923707ec041871779">chargerTerrain</a>(pTersuiv, <a class="code" href="_terrain_8c.html#a7c49ccfd3dd17d702e1932887b9e4a37">selectTerrain</a>(chemin),<a class="code" href="_sdl_jeu_8h.html#a6068a247ff9ece1b0a9773c58144906c">LARGEUR_FENETRE</a>,<a class="code" href="_sdl_jeu_8h.html#afd1a1e285af564b849b17498e82e1a41">HAUTEUR_FENETRE</a>);
<a name="l00010"></a>00010 }
<a name="l00011"></a>00011 
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 
<a name="l00014"></a><a class="code" href="_terrain_8h.html#a4ef14b5a22617c05c57c15a684181489">00014</a> <span class="keywordtype">void</span> <a class="code" href="_terrain_8c.html#a4ef14b5a22617c05c57c15a684181489" title=" Brief Description  Charge Les tileset.  ">chargerTileset</a>(FILE* F,<a class="code" href="structs_terrain.html">Terrain</a> * <a class="code" href="struct_ssprite.html#ac66841fecf0c4dc876df62666230397f">pTer</a>)
<a name="l00015"></a>00015 {
<a name="l00016"></a>00016         <span class="keywordtype">int</span> numtile,i,j;
<a name="l00017"></a>00017         <span class="keywordtype">char</span> buf[<a class="code" href="_sdl_jeu_8h.html#a8a6befd630ea1c2ab260266f7466540c">CACHE_SIZE</a>];  <span class="comment">// un buffer petite mémoire cache</span>
<a name="l00018"></a>00018         <span class="keywordtype">char</span> buf2[<a class="code" href="_sdl_jeu_8h.html#a8a6befd630ea1c2ab260266f7466540c">CACHE_SIZE</a>];  <span class="comment">// un buffer petite mémoire cache</span>
<a name="l00019"></a>00019         fscanf(F,<span class="stringliteral">&quot;%s&quot;</span>,buf); <span class="comment">// nom du fichier</span>
<a name="l00020"></a>00020         fscanf(F,<span class="stringliteral">&quot;%d %d&quot;</span>,&amp;pTer-&gt;<a class="code" href="structs_terrain.html#ae492d90d2e194e0a52854cf384d98cbf">nbtilesX</a>,&amp;pTer-&gt;<a class="code" href="structs_terrain.html#ae1aadb12d851b94edc5e17bd040ff221">nbtilesY</a>);<span class="comment">// charge le nombre de tiles en largeur et longueur</span>
<a name="l00021"></a>00021         pTer-&gt;<a class="code" href="structs_terrain.html#afd885af4967004f679bcfbe9bcf7e14f">tileplein</a> = malloc(pTer-&gt;<a class="code" href="structs_terrain.html#ae492d90d2e194e0a52854cf384d98cbf">nbtilesX</a>*pTer-&gt;<a class="code" href="structs_terrain.html#ae1aadb12d851b94edc5e17bd040ff221">nbtilesY</a>*<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>));<span class="comment">//alloue la mémoire pour chaque tile et rentre s il est plein</span>
<a name="l00022"></a>00022         <span class="keywordflow">for</span>(j=0,numtile=0;j&lt;pTer-&gt;<a class="code" href="structs_terrain.html#ae1aadb12d851b94edc5e17bd040ff221">nbtilesY</a>;j++)
<a name="l00023"></a>00023         {
<a name="l00024"></a>00024                 <span class="keywordflow">for</span>(i=0;i&lt;pTer-&gt;<a class="code" href="structs_terrain.html#ae492d90d2e194e0a52854cf384d98cbf">nbtilesX</a>;i++,numtile++)
<a name="l00025"></a>00025                 {
<a name="l00026"></a>00026                         fscanf(F,<span class="stringliteral">&quot;%s %s&quot;</span>,buf,buf2);
<a name="l00027"></a>00027                         pTer-&gt;<a class="code" href="structs_terrain.html#afd885af4967004f679bcfbe9bcf7e14f">tileplein</a>[numtile] = 0;
<a name="l00028"></a>00028                         <span class="keywordflow">if</span> (strcmp(buf2,<span class="stringliteral">&quot;plein&quot;</span>)==0 || strcmp(buf2,<span class="stringliteral">&quot;bord&quot;</span>)==0)
<a name="l00029"></a>00029                                 pTer-&gt;<a class="code" href="structs_terrain.html#afd885af4967004f679bcfbe9bcf7e14f">tileplein</a>[numtile] = 1;<span class="comment">// pour chaques tiles regarde si c&#39;est plein</span>
<a name="l00030"></a>00030                 }
<a name="l00031"></a>00031         }
<a name="l00032"></a>00032 }
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 
<a name="l00036"></a><a class="code" href="_terrain_8h.html#a675c6eb724cc04f4bd54187a9c726e22">00036</a> <span class="keywordtype">void</span> <a class="code" href="_terrain_8c.html#a675c6eb724cc04f4bd54187a9c726e22" title=" Brief Description  Charge une carte.  ">chargerNiveau</a>(FILE* F,<a class="code" href="structs_terrain.html">Terrain</a> * <a class="code" href="struct_ssprite.html#ac66841fecf0c4dc876df62666230397f">pTer</a>)
<a name="l00037"></a>00037 {
<a name="l00038"></a>00038         <span class="keywordtype">int</span> i,j;
<a name="l00039"></a>00039         fscanf(F,<span class="stringliteral">&quot;%d %d&quot;</span>,&amp;pTer-&gt;<a class="code" href="structs_terrain.html#af4ffcf044ec7b408dbad1fbb981de1c9">nbtiles_largeur_monde</a>,&amp;pTer-&gt;<a class="code" href="structs_terrain.html#ab27a7bca0b8d1bfd8c501b0b8b4c6e69">nbtiles_hauteur_monde</a>);<span class="comment">// prend la taille de la map</span>
<a name="l00040"></a>00040         pTer-&gt;<a class="code" href="structs_terrain.html#a8ee104dd02c94a9fdbba663441b4d2da">schema</a> = malloc(pTer-&gt;<a class="code" href="structs_terrain.html#af4ffcf044ec7b408dbad1fbb981de1c9">nbtiles_largeur_monde</a>*<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>*));
<a name="l00041"></a>00041         <span class="keywordflow">for</span>(i=0;i&lt;pTer-&gt;<a class="code" href="structs_terrain.html#af4ffcf044ec7b408dbad1fbb981de1c9">nbtiles_largeur_monde</a>;i++)
<a name="l00042"></a>00042                 pTer-&gt;<a class="code" href="structs_terrain.html#a8ee104dd02c94a9fdbba663441b4d2da">schema</a>[i] = malloc(pTer-&gt;<a class="code" href="structs_terrain.html#ab27a7bca0b8d1bfd8c501b0b8b4c6e69">nbtiles_hauteur_monde</a>*<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));<span class="comment">// pour chaque ligne de la map alloue la mémoire pour une colonne</span>
<a name="l00043"></a>00043         <span class="keywordflow">for</span>(j=0;j&lt;pTer-&gt;<a class="code" href="structs_terrain.html#ab27a7bca0b8d1bfd8c501b0b8b4c6e69">nbtiles_hauteur_monde</a>;j++)
<a name="l00044"></a>00044         {
<a name="l00045"></a>00045                 <span class="keywordflow">for</span>(i=0;i&lt;pTer-&gt;<a class="code" href="structs_terrain.html#af4ffcf044ec7b408dbad1fbb981de1c9">nbtiles_largeur_monde</a>;i++)
<a name="l00046"></a>00046                 {
<a name="l00047"></a>00047                         <span class="keywordtype">int</span> tmp;
<a name="l00048"></a>00048                         fscanf(F,<span class="stringliteral">&quot;%d&quot;</span>,&amp;tmp);
<a name="l00049"></a>00049                         <span class="keywordflow">if</span> (tmp&gt;=pTer-&gt;<a class="code" href="structs_terrain.html#ae492d90d2e194e0a52854cf384d98cbf">nbtilesX</a>*pTer-&gt;<a class="code" href="structs_terrain.html#ae1aadb12d851b94edc5e17bd040ff221">nbtilesY</a>)
<a name="l00050"></a>00050                                 printf(<span class="stringliteral">&quot;level tile hors limite\n&quot;</span>);<span class="comment">// teste si on sort du tileset</span>
<a name="l00051"></a>00051 
<a name="l00052"></a>00052                 pTer-&gt;<a class="code" href="structs_terrain.html#a8ee104dd02c94a9fdbba663441b4d2da">schema</a>[i][j] = tmp;<span class="comment">// charge tout les chiffres qui composent la map</span>
<a name="l00053"></a>00053                 }
<a name="l00054"></a>00054         }
<a name="l00055"></a>00055 }
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 
<a name="l00058"></a>00058 
<a name="l00059"></a><a class="code" href="_terrain_8h.html#a65ce23314928441923707ec041871779">00059</a> <span class="keywordtype">void</span> <a class="code" href="_terrain_8c.html#a65ce23314928441923707ec041871779">chargerTerrain</a>(<a class="code" href="structs_terrain.html">Terrain</a> * <a class="code" href="struct_ssprite.html#ac66841fecf0c4dc876df62666230397f">pTer</a>, <span class="keyword">const</span> <span class="keywordtype">char</span>* level,<span class="keywordtype">int</span> largeur_fenetre,<span class="keywordtype">int</span> hauteur_fenetre)
<a name="l00060"></a>00060 {
<a name="l00061"></a>00061         FILE* F;
<a name="l00062"></a>00062 
<a name="l00063"></a>00063         <span class="keywordtype">char</span> buf[<a class="code" href="_sdl_jeu_8h.html#a8a6befd630ea1c2ab260266f7466540c">CACHE_SIZE</a>];
<a name="l00064"></a>00064         F = fopen(level,<span class="stringliteral">&quot;r&quot;</span>); <span class="comment">// ouvre le niveau choisit avec const char level</span>
<a name="l00065"></a>00065         <span class="keywordflow">if</span> (!F)
<a name="l00066"></a>00066                 printf(<span class="stringliteral">&quot;fichier level introuvable\n&quot;</span>);<span class="comment">// le niveau n&#39;existe pas</span>
<a name="l00067"></a>00067         fgets(buf,<a class="code" href="_sdl_jeu_8h.html#a8a6befd630ea1c2ab260266f7466540c">CACHE_SIZE</a>,F);
<a name="l00068"></a>00068 
<a name="l00069"></a>00069         <span class="keywordflow">do</span>
<a name="l00070"></a>00070         {
<a name="l00071"></a>00071                 fscanf(F,<span class="stringliteral">&quot;%s&quot;</span>,buf);
<a name="l00072"></a>00072                 <span class="keywordflow">if</span> (strstr(buf,<span class="stringliteral">&quot;#tileset&quot;</span>))
<a name="l00073"></a>00073                         <a class="code" href="_terrain_8c.html#a4ef14b5a22617c05c57c15a684181489" title=" Brief Description  Charge Les tileset.  ">chargerTileset</a>(F,pTer);
<a name="l00074"></a>00074                 <span class="keywordflow">if</span> (strstr(buf,<span class="stringliteral">&quot;#level&quot;</span>))
<a name="l00075"></a>00075                         <a class="code" href="_terrain_8c.html#a675c6eb724cc04f4bd54187a9c726e22" title=" Brief Description  Charge une carte.  ">chargerNiveau</a>(F,pTer);
<a name="l00076"></a>00076         } <span class="keywordflow">while</span> (strstr(buf,<span class="stringliteral">&quot;#fin&quot;</span>)==NULL);
<a name="l00077"></a>00077         pTer-&gt;<a class="code" href="structs_terrain.html#a0e051c9ed4fa978482d6b31da8bf1ec1">largeur_fenetre</a> = largeur_fenetre;
<a name="l00078"></a>00078         pTer-&gt;<a class="code" href="structs_terrain.html#add43770da89e527d94605cea90ca3491">hauteur_fenetre</a> = hauteur_fenetre;
<a name="l00079"></a>00079         pTer-&gt;<a class="code" href="structs_terrain.html#a5692b40e1e9677764b6da00a4c2c24e9">xscroll</a> = 0;
<a name="l00080"></a>00080         pTer-&gt;<a class="code" href="structs_terrain.html#a276723ce5e13846eaf00445cf0206b54">focusSprite</a> = NULL;
<a name="l00081"></a>00081         fclose(F);
<a name="l00082"></a>00082 
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084 
<a name="l00085"></a>00085 
<a name="l00086"></a><a class="code" href="_terrain_8h.html#a1ed790fb54f2f8aa6a08b2490a14a03f">00086</a> <a class="code" href="struct_sprite.html">Sprite</a>* <a class="code" href="_terrain_8c.html#a1ed790fb54f2f8aa6a08b2490a14a03f" title=" Brief Description Focalise la fenêtre sur le personnage.   ">FocusScrollBox</a>(<a class="code" href="structs_terrain.html">Terrain</a>* <a class="code" href="struct_ssprite.html#ac66841fecf0c4dc876df62666230397f">pTer</a>, <a class="code" href="struct_sprite.html">Sprite</a>* pSprite, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h)
<a name="l00087"></a>00087 {
<a name="l00088"></a>00088         pTer-&gt;<a class="code" href="structs_terrain.html#a8211b66a78c1e426bc98908431d40bcf">focusx</a> = x;
<a name="l00089"></a>00089         pTer-&gt;<a class="code" href="structs_terrain.html#ac574f4029747f03bf0dc96c164cec50c">focusy</a> = y;
<a name="l00090"></a>00090         pTer-&gt;<a class="code" href="structs_terrain.html#af9815df6b8a253e3db89b907f4a1198f">focusw</a> = w;
<a name="l00091"></a>00091         pTer-&gt;<a class="code" href="structs_terrain.html#ac55032d53fb52475a4b4898f3f806b36">focush</a> = h;
<a name="l00092"></a>00092         <span class="keywordflow">return</span> pSprite;<span class="comment">// focalise la fenetre sur l&#39;avancée du personnage</span>
<a name="l00093"></a>00093 }
<a name="l00094"></a>00094 
<a name="l00095"></a>00095 
<a name="l00096"></a><a class="code" href="_terrain_8h.html#afc0d7ba57ea830d333bfc3da9c85d467">00096</a> <span class="keyword">const</span> <span class="keywordtype">char</span> <a class="code" href="_terrain_8c.html#afc0d7ba57ea830d333bfc3da9c85d467" title=" Brief Description  Test les coordonnées du terrain .  ">terGetXY</a>(<span class="keyword">const</span> <a class="code" href="structs_terrain.html">Terrain</a> *<a class="code" href="struct_ssprite.html#ac66841fecf0c4dc876df62666230397f">pTer</a>, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y)
<a name="l00097"></a>00097 {
<a name="l00098"></a>00098         assert( x&gt;=0) ;
<a name="l00099"></a>00099         assert( y&gt;=0) ;
<a name="l00100"></a>00100         assert( x&lt;pTer-&gt;nbtiles_largeur_monde ) ;
<a name="l00101"></a>00101         assert( y&lt;pTer-&gt;nbtiles_hauteur_monde ) ;
<a name="l00102"></a>00102         <span class="keywordflow">return</span> pTer-&gt;<a class="code" href="structs_terrain.html#a8ee104dd02c94a9fdbba663441b4d2da">schema</a>[y][x];
<a name="l00103"></a>00103 }
<a name="l00104"></a>00104 
<a name="l00105"></a><a class="code" href="_terrain_8h.html#a029274c956d735b0306882b42a65c028">00105</a> <span class="keywordtype">void</span> <a class="code" href="_terrain_8c.html#a029274c956d735b0306882b42a65c028" title=" Brief Description  Test les coordonnées du terrain . \">terSetXY</a>(<a class="code" href="structs_terrain.html">Terrain</a> * <a class="code" href="struct_ssprite.html#ac66841fecf0c4dc876df62666230397f">pTer</a>, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">char</span> valeur)
<a name="l00106"></a>00106 {
<a name="l00107"></a>00107         assert( x&gt;=0) ;
<a name="l00108"></a>00108         assert( y&gt;=0) ;
<a name="l00109"></a>00109         assert( x&lt;pTer-&gt;nbtiles_largeur_monde ) ;
<a name="l00110"></a>00110         assert( y&lt;pTer-&gt;nbtiles_hauteur_monde ) ;
<a name="l00111"></a>00111         pTer-&gt;<a class="code" href="structs_terrain.html#a8ee104dd02c94a9fdbba663441b4d2da">schema</a>[y][x] = valeur;
<a name="l00112"></a>00112 }
<a name="l00113"></a>00113 
<a name="l00114"></a><a class="code" href="_terrain_8h.html#a894e796af5dd61fa8e8879d74c4c197b">00114</a> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="_terrain_8c.html#a894e796af5dd61fa8e8879d74c4c197b" title=" Brief Description  Retourne la valeur dimx .  ">getDimX</a>(<span class="keyword">const</span> <a class="code" href="structs_terrain.html">Terrain</a> * <a class="code" href="struct_ssprite.html#ac66841fecf0c4dc876df62666230397f">pTer</a>)
<a name="l00115"></a>00115 {
<a name="l00116"></a>00116         <span class="keywordflow">return</span> pTer-&gt;<a class="code" href="structs_terrain.html#af4ffcf044ec7b408dbad1fbb981de1c9">nbtiles_largeur_monde</a>;
<a name="l00117"></a>00117 }
<a name="l00118"></a>00118 
<a name="l00119"></a><a class="code" href="_terrain_8h.html#af3b892a93ee78d81a03111d8b00231fe">00119</a> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="_terrain_8c.html#af3b892a93ee78d81a03111d8b00231fe" title=" Brief Description  Retourne la valeur dimy .  ">getDimY</a>(<span class="keyword">const</span> <a class="code" href="structs_terrain.html">Terrain</a> * <a class="code" href="struct_ssprite.html#ac66841fecf0c4dc876df62666230397f">pTer</a>)
<a name="l00120"></a>00120 {
<a name="l00121"></a>00121         <span class="keywordflow">return</span> pTer-&gt;<a class="code" href="structs_terrain.html#ab27a7bca0b8d1bfd8c501b0b8b4c6e69">nbtiles_hauteur_monde</a>;
<a name="l00122"></a>00122 }
<a name="l00123"></a>00123 
<a name="l00124"></a><a class="code" href="_terrain_8c.html#a7c49ccfd3dd17d702e1932887b9e4a37">00124</a> <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="_terrain_8c.html#a7c49ccfd3dd17d702e1932887b9e4a37">selectTerrain</a>(<span class="keywordtype">char</span> chemin[])
<a name="l00125"></a>00125 {
<a name="l00126"></a>00126     <span class="keywordtype">int</span> numniv;
<a name="l00127"></a>00127     srand(time(NULL));
<a name="l00128"></a>00128     numniv=(rand()% 12 )+ 1;
<a name="l00129"></a>00129     sprintf(chemin,<span class="stringliteral">&quot;data/Niveau%d.txt&quot;</span>,numniv);
<a name="l00130"></a>00130     <span class="keywordflow">return</span> chemin;
<a name="l00131"></a>00131 }
<a name="l00132"></a>00132 
<a name="l00133"></a><a class="code" href="_terrain_8h.html#a792510fb6567e176139dfd69ba70bfd2">00133</a> <span class="keywordtype">int</span> <a class="code" href="_terrain_8c.html#a792510fb6567e176139dfd69ba70bfd2" title=" Brief Description  Verifie la prochaine case.  ">verifProchCase</a>(<span class="keyword">const</span> <a class="code" href="structs_terrain.html">Terrain</a> *<a class="code" href="struct_ssprite.html#ac66841fecf0c4dc876df62666230397f">pTer</a>, <span class="keywordtype">float</span> x, <span class="keywordtype">float</span> y)
<a name="l00134"></a>00134 {
<a name="l00135"></a>00135         <span class="keywordflow">if</span> (x&gt;=0 &amp;&amp; x&lt;pTer-&gt;nbtiles_largeur_monde &amp;&amp; y&gt;=0 &amp;&amp; y&lt;pTer-&gt;nbtiles_hauteur_monde &amp;&amp; pTer-&gt;<a class="code" href="structs_terrain.html#a8ee104dd02c94a9fdbba663441b4d2da">schema</a>[(<span class="keywordtype">int</span>)y][(<span class="keywordtype">int</span>)x]!=<span class="charliteral">&#39;#&#39;</span>)
<a name="l00136"></a>00136                 <span class="keywordflow">return</span> 1;
<a name="l00137"></a>00137 
<a name="l00138"></a>00138     <span class="keywordflow">return</span> 0;
<a name="l00139"></a>00139 }
<a name="l00140"></a>00140 
<a name="l00141"></a>00141 
<a name="l00142"></a>00142 
<a name="l00143"></a><a class="code" href="_terrain_8h.html#ab31d260e306cedb6b2db5daa2cccba3d">00143</a> <span class="keywordtype">void</span> <a class="code" href="_terrain_8c.html#ae33e1396c7355287a37411d53fdf0394" title=" Brief Description  Charge la carte.   ">CopieProchCarte</a>(<a class="code" href="structs_terrain.html">Terrain</a>* <a class="code" href="struct_ssprite.html#ac66841fecf0c4dc876df62666230397f">pTer</a>, <a class="code" href="structs_terrain.html">Terrain</a> * pTersuiv)
<a name="l00144"></a>00144 {
<a name="l00145"></a>00145         <span class="keywordtype">int</span> i,j;
<a name="l00146"></a>00146         <span class="keywordtype">int</span> minx,maxx,miny,maxy;
<a name="l00147"></a>00147     minx = pTer-&gt;<a class="code" href="structs_terrain.html#a5692b40e1e9677764b6da00a4c2c24e9">xscroll</a> / pTer-&gt;<a class="code" href="structs_terrain.html#ab958ea78e1078769b3e02c1618b5c015">LARGEUR_TILE</a>-1;
<a name="l00148"></a>00148         miny = -1;
<a name="l00149"></a>00149         maxx = (minx%(pTer-&gt;<a class="code" href="structs_terrain.html#af4ffcf044ec7b408dbad1fbb981de1c9">nbtiles_largeur_monde</a>));
<a name="l00150"></a>00150         maxy = pTer-&gt;<a class="code" href="structs_terrain.html#add43770da89e527d94605cea90ca3491">hauteur_fenetre</a>/pTer-&gt;<a class="code" href="structs_terrain.html#add63ba136dabd9690e18e14258093f16">HAUTEUR_TILE</a>;<span class="comment">// prend les dimensions de la fenetre</span>
<a name="l00151"></a>00151         <span class="keywordflow">for</span>(i=0;i&lt;=maxx;i++)
<a name="l00152"></a>00152         {
<a name="l00153"></a>00153                 <span class="keywordflow">for</span>(j=miny;j&lt;=maxy;j++)
<a name="l00154"></a>00154                 {
<a name="l00155"></a>00155                                 pTer-&gt;<a class="code" href="structs_terrain.html#a8ee104dd02c94a9fdbba663441b4d2da">schema</a>[i%pTer-&gt;<a class="code" href="structs_terrain.html#af4ffcf044ec7b408dbad1fbb981de1c9">nbtiles_largeur_monde</a>][j]=pTersuiv-&gt;<a class="code" href="structs_terrain.html#a8ee104dd02c94a9fdbba663441b4d2da">schema</a>[i%pTersuiv-&gt;<a class="code" href="structs_terrain.html#af4ffcf044ec7b408dbad1fbb981de1c9">nbtiles_largeur_monde</a>][j];
<a name="l00156"></a>00156                 }
<a name="l00157"></a>00157         }
<a name="l00158"></a>00158 }
<a name="l00159"></a>00159 
<a name="l00160"></a><a class="code" href="_terrain_8h.html#a942cc755e3b7ac930ae732b7be92c648">00160</a> <span class="keywordtype">int</span> <a class="code" href="_terrain_8c.html#a942cc755e3b7ac930ae732b7be92c648" title=" Brief Description  Libère la mémoire allouée .  ">libereTerrain</a>(<a class="code" href="structs_terrain.html">Terrain</a>* <a class="code" href="struct_ssprite.html#ac66841fecf0c4dc876df62666230397f">pTer</a>)
<a name="l00161"></a>00161 {
<a name="l00162"></a>00162         <span class="keywordtype">int</span> i;
<a name="l00163"></a>00163         <span class="keywordflow">for</span>(i=0;i&lt;pTer-&gt;<a class="code" href="structs_terrain.html#ab27a7bca0b8d1bfd8c501b0b8b4c6e69">nbtiles_hauteur_monde</a>;i++)
<a name="l00164"></a>00164                 free(pTer-&gt;<a class="code" href="structs_terrain.html#a8ee104dd02c94a9fdbba663441b4d2da">schema</a>[i]);
<a name="l00165"></a>00165         free(pTer-&gt;<a class="code" href="structs_terrain.html#a8ee104dd02c94a9fdbba663441b4d2da">schema</a>);
<a name="l00166"></a>00166         free(pTer-&gt;<a class="code" href="structs_terrain.html#afd885af4967004f679bcfbe9bcf7e14f">tileplein</a>);
<a name="l00167"></a>00167         <span class="keywordflow">return</span> 0;<span class="comment">// libere la map à l&#39;aide de la fonction free</span>
<a name="l00168"></a>00168 }
<a name="l00169"></a>00169 
<a name="l00170"></a>00170 
<a name="l00171"></a>00171 
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_terrain_8c.html">Terrain.c</a>      </li>

    <li class="footer">Généré le Lundi Décembre 17 2012 01:09:40 pour Projet Jetpack par
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
